<template>
  <div id="top">
    <div class="top">
      <div class="topleft">
        <div class="img">
          <img src="../assets/images/logo.png" alt="">
        </div>
        <div class="text">供应链金融服务系统</div>
      </div>
      <div class="topRight">
        <i class="iconfont iconxiaoxitongzhi"></i>
        <div class="touxiang">
          <img src="../assets/images/people.png" alt="">
        </div>
        <span>
          <span>{{name}}</span>
          <span @click="quit" style="margin-left: 30px;">退出</span>
        </span>
      </div> 
    </div>
  </div>
</template>

<script>
export default {
  name: 'top',
  data () {
    return {
      name: ''
    };
  },
  created () {
    let user = sessionStorage.getItem('user');
    this.name = JSON.parse(user).name;
  },
  methods: {
    quit () {
      this.$router.push('/');
      // this.axios.post('AdminAPI/user/logout')
      //   .then(({data})=> {
      //     if (data.code == 200) {
      //       this.$router.push('/');
      //       sessionStorage.removeItem('token');
      //       this.$message({message: '退出登录成功',type: 'success'});
      //     } else {
      //       this.$router.push('/');
      //     }
      //   })
    }
  }
};
</script>

<style lang="scss">
  #top {
    .top {
      height: 70px;
      background-color: #1E7CF0;
      box-sizing: border-box;
      padding-left: 36px;
      padding-right: 100px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .topleft {
        height: 70px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        .text {
          font-size:28px;
          color: white;
          margin-left: 20px;
        }
      }
      .topRight {
        display: flex;
        align-items: center;
        color: white;
        i {
          font-size: 24px;
          color: white;
        }
        .touxiang {
          margin: 0 20px;
          width:42px;
          height:42px;
          border-radius:50%;
          img {
            width: 100%
          }
        }
        span {
          font-size:20px;
        }
      }
    }
  }
</style>
